﻿namespace BuzzX8.Xmpp.StreamElements.Factories
{
    public abstract class DatagramElementModel : StreamElementModel
    {
        private ErrorElementInfo errorElementInfo;

        protected DatagramElementModel(PropertyDictionary modelParameters) : base(modelParameters)
        {
            errorElementInfo = new ErrorElementInfo();
        }

        public object Id
        {
            get { return ModelParameters.ContainsKey("id") ? ModelParameters["id"] : null; }
            set { ModelParameters["id"] = value; }
        }

        public JID From
        {
            get { return ModelParameters.Get<JID>("from"); }
            set { ModelParameters["from"] = value; }
        }

        public JID To
        {
            get { return ModelParameters.Get<JID>("to"); }
            set { ModelParameters["to"] = value; }
        }

        public string XmlLang
        {
            get { return ModelParameters.Get<string>("xmlLang"); }
            set { ModelParameters["xmlLang"] = value; }
        }

        public bool HasErrorElement
        {
            get { return ModelParameters.Get<bool>("hasErrorElement"); }
            set { ModelParameters["hasErrorElement"] = value; }
        }

        public virtual ErrorElementInfo ErrorElementInfo
        {
            get { return errorElementInfo; }
        }
    }

    public class ErrorElementInfo
    {
        public string Name { get; set; }
        public string Description { get; set; }
        public string DescriptionLang { get; set; }
        public StreamElement Details { get; set; }
    }
}
